<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="10" :lg="11" :md="12" :sm="24">
            <a-form-item :label="$t('领取时间')">
              <j-date :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }" date-format="YYYY-MM-DD HH:mm:ss" :placeholder="$t('请选择开始时间')" class="query-group-cust" v-model="queryParam.createTime_begin" style="min-width: calc(50% - 10px)"></j-date>
              <span class="query-group-split-cust"></span>
              <j-date :show-time="{ defaultValue: moment('23:59:59', 'HH:mm:ss') }" date-format="YYYY-MM-DD HH:mm:ss" :placeholder="$t('请选择结束时间')" class="query-group-cust" v-model="queryParam.createTime_end" style="min-width: calc(50% - 10px)"></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">{{$t('查询')}}</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">{{$t('重置')}}</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? $t('收起') : $t('展开') }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" :loading="exloading" @click="handleExportXls($t('套餐领取汇总'))" v-has="'BisThirdGoodsUseController:export'">{{$t('导出')}}</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">{{$t('无图片')}}</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">{{$t('无文件')}}</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            {{$t('下载')}}
          </a-button>
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">{{$t('编辑')}}</a>
          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">{{$t('更多')}} <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">{{$t('详情')}}</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm :title="$t('确定删除吗?')" @confirm="() => handleDelete(record.id)">
                  <a>{{$t('删除')}}</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import moment from 'moment'

  export default {
    name: 'BisThirdGoodsUseTotal',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
    },
    data () {
      return {
        moment,
        description: '套餐领取汇总',
        queryParam:{
          groupBy:"packageId",
          createTime_begin:moment().format('YYYY-MM-DD 00:00:00'),
          createTime_end:moment().format('YYYY-MM-DD 23:59:59')
        },
        // 表头
        columns: [
          {
            title:this.$t('套餐名称'),
            align:"center",
            dataIndex: 'name'
          },
          {
            title:this.$t('领取数量'),
            align:"center",
            dataIndex: 'count'
          }
        ],
        url: {
          list: "/goods/bisThirdGoodsUse/total",
          exportXlsUrl: "/goods/bisThirdGoodsUse/exportXlsTotal",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      searchReset(){
        this.queryParam = {
          groupBy:"packageId",
          createTime_begin:moment().format('YYYY-MM-DD 00:00:00'),
          createTime_end:moment().format('YYYY-MM-DD 23:59:59')
        }
        this.loadData(1)
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'datetime',value:'createTime',text:this.$t('领取时间')})
        fieldList.push({type:'string',value:'name',text:this.$t('套餐名称'),dictCode:''})
        fieldList.push({type:'string',value:'createBy',text:this.$t('操作员'),dictCode:''})
        fieldList.push({type:'string',value:'orderId',text:this.$t('订单号'),dictCode:"bis_order,member_phone,id"})
        fieldList.push({type:'string',value:'deviceId',text:this.$t('设备ID'),dictCode:"bis_device_info,name,id"})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>